/*
 * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


// WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION!

import { int32, float32 } from "@koalaui/common"
import { KStringPtr, KBoolean, RuntimeType, runtimeType, isResource, isInstanceOf } from "@koalaui/interop"
import { NodeAttach, remember } from "@koalaui/runtime"
import { ComponentBase } from "./ComponentBase"
import { TypeChecker } from "#components"
import { ArkCommonMethodComponent } from "./ArkCommon"
import { ArkCheckboxPeer } from "./peers/ArkCheckboxPeer"
import { UseEventsProperties } from "./use_properties"
import { CommonMethod, ContentModifier } from "./ArkCommonInterfaces"
import { CheckboxAttribute, OnCheckboxChangeCallback, CheckBoxConfiguration, CheckboxOptions } from "./ArkCheckboxInterfaces"
import { ResourceColor, MarkStyle } from "./ArkUnitsInterfaces"
import { CheckBoxShape } from "./ArkEnumsInterfaces"
import { Callback_Boolean_Void } from "./SyntheticDeclarations"
/** @memo:stable */
export class ArkCheckboxComponent extends ArkCommonMethodComponent {
    getPeer(): ArkCheckboxPeer {
        return (this.peer as ArkCheckboxPeer)
    }
    /** @memo */
    public setCheckboxOptions(options?: CheckboxOptions): this {
        if (this.checkPriority("setCheckboxOptions")) {
            const options_casted = options as (CheckboxOptions | undefined)
            this.getPeer()?.setCheckboxOptionsAttribute(options_casted)
            return this
        }
        return this
    }
    /** @memo */
    public select(value: boolean): this {
        if (this.checkPriority("select")) {
            const value_casted = value as (boolean)
            this.getPeer()?.selectAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public selectedColor(value: ResourceColor): this {
        if (this.checkPriority("selectedColor")) {
            const value_casted = value as (ResourceColor)
            this.getPeer()?.selectedColorAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public shape(value: CheckBoxShape): this {
        if (this.checkPriority("shape")) {
            const value_casted = value as (CheckBoxShape)
            this.getPeer()?.shapeAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public unselectedColor(value: ResourceColor): this {
        if (this.checkPriority("unselectedColor")) {
            const value_casted = value as (ResourceColor)
            this.getPeer()?.unselectedColorAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public mark(value: MarkStyle): this {
        if (this.checkPriority("mark")) {
            const value_casted = value as (MarkStyle)
            this.getPeer()?.markAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public onChange(value: OnCheckboxChangeCallback): this {
        if (this.checkPriority("onChange")) {
            const value_casted = value as (OnCheckboxChangeCallback)
            this.getPeer()?.onChangeAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public contentModifier(value: ContentModifier<object>): this {
        if (this.checkPriority("contentModifier")) {
            const value_casted = value as (ContentModifier<object>)
            this.getPeer()?.contentModifierAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public _onChangeEvent_select(callback: ((parameter: boolean) => void)): void {
        if (this.checkPriority("_onChangeEvent_select")) {
            const callback_casted = callback as (((parameter: boolean) => void))
            this.getPeer()?._onChangeEvent_selectAttribute(callback_casted)
            return
        }
        return
    }
    public applyAttributesFinish(): void {
        // we calls this function outside of class, so need to make it public
        super.applyAttributesFinish()
    }
}

/** @memo */
export function ArkCheckbox(
  /** @memo */
  style: ((attributes: ArkCheckboxComponent) => void) | undefined,
  /** @memo */
  content_: (() => void) | undefined,
  options?: CheckboxOptions | undefined
) {
    const receiver = remember(() => {
        return new ArkCheckboxComponent()
    })
    NodeAttach<ArkCheckboxPeer>((): ArkCheckboxPeer => ArkCheckboxPeer.create(receiver), (_: ArkCheckboxPeer) => {
        receiver.setCheckboxOptions(options)
        style?.(receiver)
        content_?.()
        receiver.applyAttributesFinish()
    })
}
